package cn.ekuma.data.dao;

import com.openbravo.data.basic.BasicException;
import com.openbravo.data.loader.DataRead;
import com.openbravo.data.loader.DataWrite;
import com.openbravo.data.loader.Datas;
import com.openbravo.data.loader.I_Session;
import com.openbravo.data.loader.Session;
import com.openbravo.data.loader.TableDefinition;
import com.openbravo.data.model.Field;
import com.openbravo.format.Formats;

import cn.ekuma.data.dao.bean.AppLoger;


public class AppLogerDAO extends BaseDAO<AppLoger>{

	public AppLogerDAO(I_Session s) {
		super(s);
	}

	@Override
	public TableDefinition getTable() {
		return new TableDefinition(s,
                "APP_LOGER",
                new Field[]{
				     new Field("ID",Datas.STRING,Formats.STRING),
                     new Field("USERID",Datas.STRING,Formats.STRING),
                     new Field("HOSTNAME",Datas.STRING,Formats.STRING),
                     new Field("CURDATE",Datas.TIMESTAMP,Formats.TIMESTAMP),
                     new Field("LOGTYPE",Datas.INT,Formats.INT),
                     new Field("CHANGEVALUE",Datas.STRING,Formats.STRING),
                     new Field("OBJCLASS",Datas.STRING,Formats.STRING),
                     new Field("OBJID",Datas.STRING,Formats.STRING)
                    },
                new int[]{0});
	}
	
	@Override
	public AppLoger readValues(DataRead dr,AppLoger obj) throws BasicException {
		if(obj==null)
			obj=new AppLoger();
		obj.setId(dr.getString(1));
		obj.setUserId(dr.getString(2));
		obj.setHostName(dr.getString(3));
		obj.setCreateDate(dr.getTimestamp(4));
		obj.setType(dr.getInt(5));
		obj.setChangeValue(dr.getString(6));
		obj.setObjClass(dr.getString(7));
		obj.setObjId(dr.getString(8));
		return obj;
	}

	@Override
	public void writeInsertValues(DataWrite dp, AppLoger obj)
			throws BasicException {
		dp.setString(1,obj.getId());
		dp.setString(2,obj.getUserId());
		dp.setString(3, obj.getHostName());
		dp.setTimestamp(4,obj.getCreateDate());
		dp.setInt(5,obj.getType());
		dp.setString(6,obj.getChangeValue());
		dp.setString(7,obj.getObjClass());
		dp.setString(8,obj.getObjId());
	}

	@Override
	public Class getSuportClass() {
		return AppLoger.class;
	}
}
